#include <iostream>
#include <string>
#include <algorithm>
#define N 50
using namespace std;



int main(){

int numbers[N];
int n;
int i;
int max=0;
int min;
int posmax;
int posmin;
int aux;
cout<<"Type the number of elements int the array"<<endl;
cin>>n;

for(i=0; i<n; i++){
	cin>>numbers[i];}
cout<<"The original array is ";
for(i=0; i<n; i++){
	cout<<numbers[i]<<" ";}
cout<<endl;

for(i=0; i<n; i++){
	if(numbers[i] > max){
	max=numbers[i];
	posmax=i;}
	else if(numbers[i] < min){
	min=numbers[i];
	posmin=i;}
}


cout<<"Max is "<<max <<" Min is " << min<<endl;

aux=numbers[posmax];
numbers[posmax]=numbers[posmin];
numbers[posmin]=aux;

cout<<"The changed arrays is ";

for(i=0; i<n; i++){
	cout<<numbers[i]<<" ";}
	

return 0;

}


	
 
